Execute SELECT Query on a SQL Database

Description

The Execute SELECT Query on a SQL Database action allows you to execute a SQL SELECT statement (a query) on a remote SQL database (or Excel spreadsheet) to retrieve one or more record(s). Alpha Anywhere will use AlphaDAO (Alpha Data Access Objects) to connect to the remote database.

It is not necessary to use the Connect to SQL Database action before using this action.

Once you have executed the query, you can:

  • preview the data in a window

  • generate sample code to show how to loop through the rows of returned data

  • save the result to a variable in the form of a CR-LF delimited list

  • perform other actions

Procedure

  1. Enter the required connection string into the Options > Connection string property. If you do not have a ready-made connection string, you may click to display the Connection String dialog.

    • 1. Optionally, select a named connection string from the drop-down list.

    • 2. Optionally, select Specify a connection string and click Build to display the Create SQL Connection String dialog.

    • 3. Click OK to return to the Script Genie.

  2. Make a selection from the Options > SQL Statement type list. The options are:

    • " Portable " - the generic, multi-database version of SQL that allows use of the SQL Genie.

    • "Native SQL Syntax" - appropriate for the database you selected

    • "Stored Procedure" - the name of a stored SQL procedure to run

  3. If you selected "Portable" or "Native SQL Syntax" in step 2, click '...' in the Options > SQL Statement property to display the SQL Genie. Otherwise, enter the name of the SQL stored procedure to run.

  4. Optionally, click '...' in the Options > Arguments property to display the Define/Edit Arguments dialog. Arguments provide values to use in filter and order expressions. Argument values may come from variables or from user selections at run time.

  5. Optionally, click in the Options > Arguments property to display the Define/Edit Arguments dialog. Arguments provide values to use in filter and order expressions. Argument values may come from variables or from user selections at run time.

    • "Open Window to Preview Result"

    • "Generate code to loop over rows"

    • "Dump results to a variable"

  6. Optionally, click Preview Records. Note that this function does not use any defined arguments.

  7. Click Next >.

  8. Optionally, enter a comment that describes the action.

  9. Click Finish.

  10. If you selected "Generate code to loop over rows" in step 5, right click on the action and select View Xbasic.

Limitations

Desktop Applications Only

See Also